<template>
  <div>
    <el-dialog title="编辑招标" :visible="dialogVisible" @close="handleClose">
      <el-form ref="AddInvite" :model="EditInviteData" size="small" label-width="120px">
        <el-form-item label="标的名称">
          <el-input v-model.trim="EditInviteData.title" placeholder="标的名称" />
        </el-form-item>
        <el-form-item label="项目名">
          <el-input v-model.trim="EditInviteData.projectName" placeholder="项目名" />
        </el-form-item>
        <el-form-item label="项目号">
          <el-input v-model.trim="EditInviteData.projectSerial" placeholder="项目号" />
        </el-form-item>
        <el-form-item label="项目概况">
          <el-input v-model.trim="EditInviteData.summary" placeholder="项目概况" />
        </el-form-item>
        <el-form-item label="发布人">
          <el-input
            v-model.trim="EditInviteData.publisher"
            :readonly="isReadOnly"
            placeholder="发布人"
          />
        </el-form-item>
        <el-form-item label="发布人邮箱">
          <el-input
            v-model.trim="EditInviteData.publisherMailAddr"
            :readonly="isReadOnly"
            placeholder="发布人邮箱"
          />
        </el-form-item>
        <el-form-item label="部门领导">
          <el-input v-model.trim="EditInviteData.deptLeader" placeholder="部门领导" />
        </el-form-item>
        <el-form-item label="部门领导邮箱">
          <el-input v-model.trim="EditInviteData.deptLeaderMailAddr" placeholder="部门领导邮箱" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" plain size="medium" @click="submit">{{ $t('button.Submit') }}</el-button>
          <!-- <el-button size="medium" @click="handleClose">{{ $t('button.Cancel') }}</el-button> -->
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { InviteUpdate } from '@/api/SRM'
import elDragDialog from '@/components/el-drag-dialog' // base on element-ui
import { Message } from 'element-ui'

export default {
  name: 'EditInviteDialog',
  directives: { elDragDialog },
  props: {
    editInviteDialogFlag: {
      default: false
    },
    InviteInfo: {}
  },
  data() {
    return {
      dialogVisible: false,
      isReadOnly: false,
      EditInviteData: {
        id: 0,
        title: '',
        projectName: '',
        projectSerial: '',
        summary: '',
        publisher: '',
        inviteInfoMailAddr: '',
        deptLeader: '',
        deptLeaderMailAddr: ''
      }
    }
  },
  watch: {
    editInviteDialogFlag() {
      this.dialogVisible = this.editInviteDialogFlag
    },
    InviteInfo() {
      for (const key in this.InviteInfo) {
        this.EditInviteData[key] = this.InviteInfo[key]
      }
    }
  },
  mounted() {},
  methods: {
    async submit() {
      try {
        const res = await InviteUpdate(this.EditInviteData)
        Message.success('创建成功')
        this.dialogVisible = false
      } catch (error) {
        console.log('EditInvite->submit', error.message)
        Message.error('创建失败')
      }
    },
    handleClose() {
      this.$emit('updateValue')
      this.$emit('update:editInviteDialogFlag', false)
    }
  }
}
</script>

<style>
</style>
